
function def(obj_id,text){
	var obj = $('#'+obj_id);
	obj.blur(function(){out()});
	obj.focus(function(){on()});
	text = text==''?'请输入':text;

	function on(){
		obj.css('color','#000')
		if(obj.val()==text){
			obj.val('');
		}
	}
	
	function out(){
		if(obj.val()=='' || obj.val()==text){
			obj.css('color','#999').val(text);
		}
	}
	out();
}


function checkall(form, prefix) {
	var check = $('#chkall').attr("checked")
	$("input[type='checkbox']").each(function(){
		if(this.id!='chkall'){
			$(this).attr("checked",check);
			bg_select(this);
		}
	})
}

function cancelall(){
	$("input[type='checkbox']").each(function(){
		$(this).attr("checked",false);
	})
}

function op(op,value,id){
	
	
	//删除
	if(op == 'del'){
		var s = confirm("真的要删除选中的记录吗?");
		if(s){
			if(id){
				cancelall();
				$('#'+id).attr('checked',true);
			}
			getid('form').action = getid('form').action+'/'+op;
			getid('form').submit();
		}
	}
	//清空
	else if(op == 'clean'){
		var s = confirm("真的要删除所有记录吗?");
		if(s){
			getid('form').action = getid('form').action+'/'+op;
			getid('form').submit();
		}
	}
	//增加显示
	else if(op == 'ps'){
		var ps = prompt('每页显示多少条记录?','10');
		getid('p').value = 1;
		getid('ps').value = ps;
		getid('form').submit();
	}
	//改排序 order
	else if(op == 'order'){
		if(getid('order').value == value){
			//改升降顺
			if(getid('by').value == 'ASC'){getid('by').value = 'DESC';}
			else{getid('by').value = 'ASC';}
		}else{
			//改order边个
			getid('order').value = value;
			getid('by').value = 'ASC';
			getid('p').value = 1;
		}
		getid('form').submit();
	}
	//开关制
	else if(op == 'onoff'){
		if(id){
			cancelall();
			$('#'+id).attr('checked',true);
		}
		getid('form').action = getid('form').action+'/'+op;
		getid('value').value = value;
		getid('form').submit();
	}
	//换页 page
	else if(op == 'page'){
		var page = value.split(",");
		if(page[0] == '+'){
			if(Number(page[1])+1 <= page[2]){
				getid('p').value = Number(page[1])+1;
				getid('form').submit();
			}
		}
		else if(page[0] == '-'){
			if(page[1] != 1){
				getid('p').value = Number(page[1])-1;
				getid('form').submit();
			}
		}else{
			if(Number(page[0]) <= Number(page[1])){
				getid('p').value = page[0];
				getid('form').submit();
			}
		}
	}
	//转到
	else if(op == 'goto'){
		var p = prompt('要转到第几页? (1-'+value+')','');
		if(p>0 && p<=value){
			getid('p').value = p;
			getid('form').submit();
		}
	}
	//进入目录
	else if(op == 'gotolv'){
		var lv = Number(getid('lv').value);
		if(lv == 4){
			alert('不能再进入');
		}else{
			getid('kw').value = '';
			getid('p').value = 1;
			getid('fid').value = value;
			getid('lv').value = lv + 1;
			getid('form').submit();
		}
	}
	//返回上级目录
	else if(op == 'backlv'){
		var lv = Number(getid('lv').value);
		getid('kw').value = '';
		getid('p').value = 1;
		getid('act').value = op;
		getid('lv').value = lv - 1;
		getid('form').submit();
	}
	else{
		getid('form').action = getid('form').action+'/'+op;
		getid('form').submit();
	}
}